package com.desire.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @author LittleDesire
 * @description
 * @date 2022-04-27 周三 19:18
 * @since 17
 */
public class WindowCondition implements Condition {
    public static void main(String[] args) {
        String property = System.getProperty("os.name");
        System.out.println(property);
        Properties properties = System.getProperties();
        Set<Map.Entry<Object, Object>> entries = properties.entrySet();
        for (Map.Entry<Object, Object> next : entries) {
            System.out.println(next.getKey() + " --  " + next.getValue());
        }
    }

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        String os = System.getProperty("os.name");
        return os.contains("Windows 10");
    }
}
